<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('专利列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>序号：</label>
                                <input type="text" name="numbers"/>
                            </li>
                          <!--  <li>
                                <label>专利类型：</label>
                                <input type="text" name="ptype"/>
                            </li>-->
                            <li>
                                <label>专利名称：</label>
                                <input type="text" name="pname"/>
                            </li>
                            <li>
                                <label>公开号：</label>
                                <input type="text" name="opens"/>
                            </li>
                            <li>
                                <label>申请人：</label>
                                <input type="text" name="sname"/>
                            </li>
                            <li>
                                <label>发明人：</label>
                                <input type="text" name="fname"/>
                            </li>
                            <li>
                                <label>其他参与人员：</label>
                                <input type="text" name="qname"/>
                            </li>
                            <li class="select-time">
                                <label>申请日：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginStime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endStime]"/>
                            </li>
                            <li class="select-time">
                                <label>授权日：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginQtime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endQtime]"/>
                            </li>
                            <li>
                                <label>赋分：</label>
                                <input type="text" name="grade"/>
                            </li>
                            <li>
                                <label>奖金：</label>
                                <input type="text" name="bonus"/>
                            </li>
                            <li>
                                <label>上传人：</label>
                                <input type="text" name="shname"/>
                            </li>
                            <li>
                                <label>附件：</label>
                                <input type="text" name="accessory"/>
                            </li>
                            <li>
                                <label>审批状态：</label>
                                <select name="status" th:with="type=${@dict.getType('sys_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>备案：</label>

                                <select name="onRecords" th:with="type=${@dict.getType('sys_records')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                    </option>
                                </select>

                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:patent:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:patent:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:patent:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:patent:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:patent:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:patent:remove')}]];
        var datas = [[${@dict.getType('sys_records')}]];
        var datass = [[${@dict.getType('sys_status')}]];
        var prefix = ctx + "ruoyi/patent";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "专利",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'numbers',
                    title: '序号'
                },
                {
                    field: 'ptype',
                    title: '专利类型'
                },
                {
                    field: 'pname',
                    title: '专利名称'
                },
                {
                    field: 'opens',
                    title: '公开号'
                },
                {
                    field: 'sname',
                    title: '申请人'
                },
                {
                    field: 'fname',
                    title: '发明人'
                },
                {
                    field: 'qname',
                    title: '其他参与人员'
                },
                {
                    field: 'stime',
                    title: '申请日'
                },
                {
                    field: 'qtime',
                    title: '授权日'
                },
                {
                    field: 'grade',
                    title: '赋分'
                },
                {
                    field: 'bonus',
                    title: '奖金'
                },
                    {
                        title: '查看文件',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            if (row.accessory==null||row.accessory==''){
                                actions.push('<p>未提交</p> ');
                                return actions.join('');
                            }else{
                                actions.push('<a href=\''+row.accessory+'\' target="_blank" rel="nofollow">查看文件</a> ');
                                return actions.join('');
                            }
                            return actions.join('');
                        }
                    },
                {
                    field: 'onRecords',
                    title: '备案',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'status',
                    title: '审批状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datass, value);
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        if (row.onRecords===0){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.id + '\')"><i class="fa fa-user"></i>提交备案</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if (row.status===1){
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="revocation(\'' + row.id + '\')"><i class="fa fa-user"></i>撤销</a> ');
                        }else if (row.onRecords===3){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.id + '\')"><i class="fa fa-user"></i>重新提交备案</a> ');
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if (row.onRecords===1&&row.status===0||row.status===2){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitForApproval(\'' + row.id + '\')"><i class="fa fa-user"></i>提交申请</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function submitApply(id) {
            $.modal.confirm("确认要提交申请备案吗?", function() {
                var url = prefix + "/submitApply";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }

        function revocation(id) {
            $.modal.confirm("确认要撤销申请吗?", function() {
                var url = prefix + "/revocation";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }

        function submitForApproval(id) {
            $.modal.confirm("确认要提交申请吗?", function() {
                var url = prefix + "/submitForApproval";
                var data = { "id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }
    </script>
</body>
</html>